import router from './index'
import store from '../store/index'
router.beforeEach((to, from, next) => {
  if (to.path !== '/login' && !store.state.user.token) {
    next('/login')
  } else if (to.path === '/login' && store.state.user.token) {
    next(from.path)
  } else {
    next()
  }
})
